// src/router/index.js
import { createRouter, createWebHistory } from 'vue-router';
import Login from '../pages/Login.vue';
import Register from '../pages/Register.vue';
import AdminRedirectPage from '../pages/AdminRedirectPage.vue';
import TeacherRedirectPage from '../pages/TeacherRedirectPage.vue';
import StudentRedirectPage from '../pages/StudentRedirectPage.vue';
import PracticeView from '../components/PracticeView.vue';
import User from '../components/UserManagement.vue';
import Subject from '../components/SubjectManager.vue';
import UserProfile from '../components/UserProfile.vue';
import ExamManage from '../components/ExamManage.vue';
import PaperManager from '../components/PaperManager.vue';
import Manage from '../components/Manage.vue';

import GradingPapers from '../components/GradingPapers.vue';
import Scores from '../components/Scores.vue';

import music from '../play/Music.vue';
import game from '../play/GameView.vue';

import blogList from '../blog/BlogList.vue';
import blogAdmin from '../blog/BlogAdmin.vue';

import manages from '../management/manage.vue'
import studentManagement from '../management/Student.vue'
import teacherManagement from '../management/Teacher.vue'

import chats from '../chat/ChatDemo.vue'


const routes = [
  { path: '/', component: Login },
  { path: '/api/user/login', component: Login },
  { path: '/api/user/register', component: Register },
  { path: '/api/user/AdminRedirectPage', component: AdminRedirectPage },
  { path: '/api/user/TeacherRedirectPage', component: TeacherRedirectPage },
  { path: '/api/user/StudentRedirectPage', component: StudentRedirectPage },

  { path: '/api/student/GradingPapers', component: GradingPapers },
  { path: '/api/student/Scores', component: Scores },

  { path: '/api/question/questions', component: PracticeView },
  { path: '/api/user/users', component: User ,
    meta: { userSystemRole: "admin" },
  },
  { path: '/api/subject/subjects', component: Subject,
    meta: { userSystemRole: "admin" },
  },
  { path: '/api/userProfile/userProfiles', component: UserProfile },
  { path: '/api/examManage/examManages', component: ExamManage },
  { path: '/api/paperManager/paperManagers', component: PaperManager },
  { path: '/api/manage/manages', component: Manage },

  { path: '/api/management/managements', component: manages },
  { path: '/api/management/studentManagements', component: studentManagement },
  { path: '/api/management/teacherManagements', component: teacherManagement },

  { path: '/api/music', component: music },
  { path: '/api/game', component: game },

  { path: '/api/blogs', component: blogList },
  { path: '/api/admin', component: blogAdmin },

  { path: '/api/chat', component: chats },

{
  path: '/api/detail/:id',
  component: () => import('../blog/BlogDetail.vue'),
},


{
  path: "/api/paper/answer/:name",  // 如果你用的是 name 查询试卷详情
  name: "AnswerPage",
  component: () => import("../components/AnswerPaper.vue"), // 你的答题页面路径
},

  
{
  path: '/api/paper/detail/:name',
  component: () => import('../components/PaperDetail.vue')
}

];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
